//
// //接入机型占比
//
var COLOR = {
	MACHINE:{
		TYPE_A:'#0175EE',
		TYPE_B:'#D89446',
		TYPE_C:'#373693',
		TYPE_D:'#25AE4F',
		TYPE_E:'#06B5C6',
		TYPE_F:'#009E9A',
		TYPE_G:'#AC266F'
	}
};



function renderChartBar01(position,jsonstr){
	var json = JSON.parse(jsonstr)
	var myChart = echarts.init(document.getElementById(position));
		myChart.setOption(
					 {
						
						tooltip : {
							trigger: 'item',
							formatter: "{b} : {c} ({d}%)"
						},
						toolbox: {
						},
						label:{
							normal:{
								show: true, 
								formatter: "{b} \n{d}%"
							} 
						},
						calculable : true,
						color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);},
						series : [
							{
								name:'lalal',
								type:'pie',
								radius : [40, 80],
								center : ['40%', '40%'],
								roseType : 'area',
								data:json
								
							}
						]
					}
		);

}
function renderLayer04Left(position,factor,count){
	var myChart = echarts.init(document.getElementById(position));
	myChart.setOption(
		{
			
			tooltip : {
				trigger: 'axis'
			},
			grid: {
				left: '3%',
				right: '4%',
				bottom: '5%',
				top:'4%',
				containLabel: true
			},
			xAxis :
			{
				type : 'category',
				boundaryGap : false,
				data : factor,
				axisLabel:{
					textStyle:{
						color:"black", //刻度颜色
						fontSize:8  //刻度大小
					},
					rotate:45,
					interval:2
				},
				axisTick:{show:false},
				axisLine:{
					show:true,
					lineStyle:{
						color: '#0B3148',
						width: 1,
						type: 'solid'
					}
				}
			},
			yAxis : 
			{
				type : 'value',
				axisTick:{show:false},
				axisLabel:{
					textStyle:{
						color:"black", //刻度颜色
						fontSize:8  //刻度大小
						}
				},
				axisLine:{
					show:true,
					lineStyle:{
						color: '#0B3148',
						width: 1,
						type: 'solid'
					}
				},
				splitLine:{
					show:false
				}
			},
			tooltip:{
				formatter:'{c}',
				backgroundColor:'#FE8501'
			},
			series : [
				{
					name:'日登录次数',
					type:'line',
					smooth:true,
					areaStyle:{
						normal:{
							color:new echarts.graphic.LinearGradient(0, 0, 0, 1, [{offset: 0, color: '#026B6F'}, {offset: 1, color: '#012138' }], false),
							opacity:0.2
						}
					},
					itemStyle : {  
                            normal : {  
                                  color:'#009991'
                            },
							lineStyle:{
								normal:{
								color:'#009895',
								opacity:1
							}
						}
                    },
					symbol:'none',
					data:count
				}
			]
		}
	
	);
}

function renderLayer04Right(position,factor,count){
	var myChart = echarts.init(document.getElementById(position));
	myChart.setOption({
			
			tooltip: {
				trigger: 'axis'
			},
			legend: {
				top:20,
				right:5,
				orient:'vertical',
				data:[
						{name:'数量',icon:'circle'},
						/*{name:'出库',icon:'circle'},
						{name:'客户投诉',icon:'circle'}*/
					]
			},
			grid: {
				left: '3%',
				right: '16%',
				bottom: '3%',
				top:'3%',
				containLabel: true
			},
			xAxis: {
				type: 'category',
				boundaryGap: false,
				axisTick:{show:false},
				axisLabel:{
					textStyle:{
						color:"black", //刻度颜色
						fontSize:8  //刻度大小
						}
				},
				axisLine:{
					show:true,
					lineStyle:{
						color: '#0B3148',
						width: 1,
						type: 'solid'
					}
				},
				data: factor
			},
			yAxis: {
				type: 'value',
				axisTick:{show:false},
				axisLabel:{
					textStyle:{
						color:"black", //刻度颜色
						fontSize:8  //刻度大小
						}
				},
				axisLine:{
					show:true,
					lineStyle:{
						color: '#0B3148',
						width: 1,
						type: 'solid'
					}
				},
				splitLine:{
					show:false
				}
			},
			series: [
						{
							name:'数量',
							type:'line',
							itemStyle : {  
									normal : {  
									color:'#F3891B'
								},
								lineStyle:{
									normal:{
									color:'#F3891B',
									opacity:1
										}
								}
							},  
							data:count
						}
					]
		}	
	);
}

function get60MinutesScale()
{
	var currDate = new Date();
	var odd = currDate.getMinutes()%10;
	var returnArr = new Array();
	currDate.setMinutes(currDate.getMinutes()-odd);
	for(var i = 0; i <7; i++){
		returnArr.push(currDate.getHours()+":"+(currDate.getMinutes()<10?("0"+currDate.getMinutes()):currDate.getMinutes()));
		currDate.setMinutes(currDate.getMinutes()-10);
	}
	return returnArr.reverse();
}


function getLatestDays(num)
{
	var currentDay = new Date();
	var returnDays = [];
	for (var i = 0 ; i < num ; i++)
	{
		currentDay.setDate(currentDay.getDate() - 1);
		returnDays.push((currentDay.getMonth()+1)+"/"+currentDay.getDate());
	}
	return returnDays.reverse();
}
//自定义的柱状图
function simpleBar(position,factor,count) {
    var myChart = echarts.init(document.getElementById(position));
    // 过渡---------------------
    myChart.showLoading({
        text: '正在努力的读取数据中...',    //loading话术
    });

    myChart.hideLoading();

    // 指定图表的配置项和数据
    myChart.setOption({
        
        itemStyle:{
            normal:{
                color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}
            }
        },
        tooltip: {},
        xAxis: {
            data: factor
        },
        yAxis: {},
        series: [{
            name: '销量',
            type: 'bar',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            itemStyle: {
                normal: {
                    // 随机显示
                    color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}

                },
            },
            data: count
        }]
    });
}
